/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import com.click.app.Functions;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 *
 * @author ariel
 */
@Entity
@Table(name = "asignation_cuts")
public class AsignationCut extends BaseObject{

    private static final long serialVersionUID = 1L;
    
    private Long id;
    private Double quantityUsed;
    private PackageDetail packageDetail;
    private CutProcess cutProcess;

    private Double quantityUsedFail;
    private Double priceQuantUsedFail;
    private Double totalQuantUsedFail;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_asignation_cut", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "quantity_used", precision = 6, scale = 0)
    public Double getQuantityUsed() {
        return Functions.getDouble3Decimal(quantityUsed);
    }

    public void setQuantityUsed(Double quantityUsed) {
        this.quantityUsed = Functions.getDouble3Decimal(quantityUsed);
    }

    @JoinColumn(name = "id_package_detail", referencedColumnName = "id_package_detail")
    @ManyToOne(optional = false)
    public PackageDetail getPackageDetail() {
        return packageDetail;
    }

    public void setPackageDetail(PackageDetail packageDetail) {
        this.packageDetail = packageDetail;
    }

    @JoinColumn(name = "id_cut_process", referencedColumnName = "id_cut_process")
    @ManyToOne(optional = false)
    public CutProcess getCutProcess() {
        return cutProcess;
    }

    public void setCutProcess(CutProcess cutProcess) {
        this.cutProcess = cutProcess;
    }

    @Column(name = "price_quantity_used_fail")
    public Double getPriceQuantUsedFail() {
        return Functions.getDouble3Decimal(priceQuantUsedFail);
    }

    public void setPriceQuantUsedFail(Double priceQuantUsedFail) {
        this.priceQuantUsedFail = Functions.getDouble3Decimal(priceQuantUsedFail);
    }

    @Column(name = "quantity_used_fail")
    public Double getQuantityUsedFail() {
        return Functions.getDouble3Decimal(quantityUsedFail);
    }

    public void setQuantityUsedFail(Double quantityUsedFail) {
        this.quantityUsedFail = Functions.getDouble3Decimal(quantityUsedFail);
    }

    @Column(name = "total_quantity_used_fail")
    public Double getTotalQuantUsedFail() {
        return Functions.getDouble3Decimal(totalQuantUsedFail);
    }

    public void setTotalQuantUsedFail(Double totalQuantUsedFail) {
        this.totalQuantUsedFail = Functions.getDouble3Decimal(totalQuantUsedFail);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AsignationCut)) {
            return false;
        }
        AsignationCut other = (AsignationCut) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
                .append(this.id).append(this.quantityUsed)
                .append(this.packageDetail.getId()).append(this.cutProcess.getId()).toString();
    }

}
